package demo.thread.synMethod;

/**
 * 线程A
 */
public class ThreadA extends Thread{

    public ThreadA(String name) {
        super(name);
    }

    @Override
    public synchronized void run() {
        try {
            // 等待10秒
            System.out.println("A:过10秒后将flag设置为true");
            Thread.sleep(1000*10);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        ShareData shareData = ShareData.getInstance();
        shareData.setFlag(true);
        System.out.println("A:flag已经设置为true");
    }
}
